package com.example.beikeyigou;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import com.example.beikeyigou.login.UserBean;
import com.example.beikeyigou.untils.SaveUserUtils;

public class SettingActivity extends AppCompatActivity {

    private Button meBtn,changeBtn;
    private UserBean.DataBean dataBean;
    private ImageView backIv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);

        initView();
        setListener();
    }

    private void setListener() {

        meBtn.setOnClickListener(onClickListener);
        changeBtn.setOnClickListener(onClickListener);
        backIv.setOnClickListener(onClickListener);
    }



    private void initView() {
        meBtn = findViewById(R.id.setting_me_btn);
        changeBtn = findViewById(R.id.setting_changePwd_btn);
        dataBean = SaveUserUtils.getUserInfo(this);
        backIv = findViewById(R.id.setting_back);

    }



    View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            int id = v.getId();  // 获取到被点击的id
            switch (id) {
                case R.id.setting_me_btn:
                    //个人信息

                    break;
                case R.id.setting_changePwd_btn:
                    //修改密码

                    if (dataBean == null){
                        Toast.makeText(SettingActivity.this,"请登录后再来",Toast.LENGTH_SHORT).show();
                    }
                    else {
                        Intent intent = new Intent(SettingActivity.this,QuestionActivity.class);
                        startActivity(intent);
                    }
                    break;

                case R.id.setting_back:
                    finish();
                    break;

            }
        }
    };



}